package org.sky.cloud.common.model;

import java.io.Serializable;

public class RestResult<T> implements Serializable {

    private int code;

    private String message;

    private T data;

    public RestResult(){

    }

    public RestResult(int code, T data) {
        this.code = code;
        this.data = data;
    }

    public RestResult(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public RestResult(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public static <T> Builder<T> builder() {
        return new Builder<T>();
    }


    public static class Builder<T> {

        private int code;

        private String message;

        private T data;

        public Builder<T> code(int code) {
            this.code = code;
            return this;
        }

        public Builder<T> message(String message) {
            this.message = message;
            return this;
        }

        public Builder<T> data(T data) {
            this.data = data;
            return this;
        }

        public RestResult<T> build(){
            return new RestResult<T>(code, message, data);
        }
    }
}
